package com.yauchu.kegra.graph;

import java.util.ArrayList;
import java.util.Iterator;

import android.widget.LinearLayout;

import com.yauchu.kegra.oelib.Operator;

public class OperatorNode extends GraphNode{
	public Operator operator;
	public OperatorNode(LinearLayout dL, Operator op)
		{
		super(dL,op);
		this.operator=op;
		}
	
	@Override
	public String getFullStringRepresentation()
	{
		
		GraphContainer negr= this.graphContainer;
		
		
		return operator.getExspression(negr.getArguments(this));
		
		
	}
	
	public void replaceOperator(String newop)
	{	
		
		operator= new Operator(newop);
	}
	
	/*
	public  void switchToColorCodedView()
	{
		this.fullStringRepresentation=getColorCodedRepresentation();
		super.refreshFullRepresentation();
	}
	
	@Override
	public void refreshFullRepresentation()
	{
		this.fullStringRepresentation=getFullStringRepresentation();
		super.refreshFullRepresentation();
		
	}
	*/
	public String getGenericStringRepresentation()
	{
		return genericStringRepresentation;
	}
	public void Refresh() 
	{
		
	}
	@Override
	public void setGenericRepresentation(String newGR)
	{
		this.genericStringRepresentation=newGR;
		replaceOperator(newGR);
	}
	
	public String getColorCodedRepresentation() {
		 ArrayList<String> colors = new ArrayList<String>();
		 colors.add("{\\color{red}\\Box}");
			colors.add("{\\color{green}\\Box}");
			colors.add("{\\color{blue}\\Box}");
			colors.add("{\\color{yellow}\\Box}");
			colors.add("{\\color{magenta}\\Box}");
			colors.add("{\\color{orange}\\Box}");

		 Iterator<String> colorsIterator = colors.iterator();
		return this.operator.getExspression(colorsIterator);
	}
	/*
	public String getArguments(int i)
	{
		//TODO this is a stub
		switch(i){
		case 1:
		{return "a";}
		case 2:
		{return "fdsb";}
		}
		return "c";
	}
	*/

}
